from time import sleep
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.keys import Keys

if __name__ == '__main__':

    driver = webdriver.Chrome(service = Service(r'd:\python\chromedriver.exe'))
    driver.get("https://www.ypshuo.com/")
    driver.maximize_window()
    # #首页窗口句柄
    # handel1=driver.current_window_handle
    #定位登录入口
    loginrk=driver.find_element(By.XPATH,"//*[@id='app']/header/div/div[2]/div[1]").click()
    #定位邮箱账号
    user=driver.find_element(By.XPATH,"//*[@id='app']/div[3]/div/div[2]/div/div/div[1]/div[1]/input").send_keys("2114369437@qq.com")
    #定位密码
    pwd=driver.find_element(By.XPATH,"//*[@id='app']/div[3]/div/div[2]/div/div/div[1]/div[2]/input").send_keys("QQ123123")
    #定位点击登录
    login = driver.find_element(By.XPATH, "//*[@id='app']/div[3]/div/div[2]/div/div/div[1]/button").click()
    sy=driver.find_element(By.XPATH,"//*[@id='app']/div[1]/div[1]/div[1]/div[3]/div[2]/div[1]/div[2]/div[1]/a").click()
    sleep(2)
    # # #定位搜索框并输入内容
    # # input_text=driver.find_element(By.XPATH,"//*[@id='app']/header/div/div[1]/div/div[2]/input")
    # # input_text.send_keys("寻宝全世界")
    # #定位搜索框并输入搜索不到的内容
    # input_text = driver.find_element(By.XPATH, "//*[@id='app']/header/div/div[1]/div/div[2]/input")
    # input_text.send_keys("雾里")
    # sleep(2)
    # #进入搜索
    # input_text.send_keys(Keys.ENTER)
    # sleep(2)
    # #定位搜索不到的书籍,弹出推荐
    # driver.find_element(By.XPATH,"//*[@id='app']/div[1]/div[3]/button/span").click()
    # sleep(2)
#
#
#     # #点击搜索
# #     # #点击寻宝全世界1
# #     # WebDriverWait(driver, 5, 0.5).until(
# #     #     lambda p: p.find_element(By.XPATH, "//*[@id=‘app’]/div[1]/div[1]/div[1]/div[2]/div[1]/a"))
# #     # driver.find_element(By.XPATH,"//*[@id=‘app’]/div[1]/div[1]/div[1]/div[2]/div[1]/a").click()
# #     # # 获取所有窗口句柄
# #     # handel2 = driver.window_handles
# #     # driver.switch_to.window(handel2[1])
# #     # 点击寻宝全世界2
# #     WebDriverWait(driver, 5, 0.5).until(
# #     lambda p: p.find_element(By.XPATH, "//*[@id=‘app’]/div[1]/div[1]/div[2]/div[2]/div[1]/a"))
# #     driver.find_element(By.XPATH, "//*[@id=‘app’]/div[1]/div[1]/div[2]/div[2]/div[1]/a").click()
# #     #获取所有窗口句柄
# #     handel2 = driver.window_handles
# #     #切换书籍窗口
# #     driver.switch_to.window(handel2[1])
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #     # driver.get("https://you.mashibing.com/")
# #     # driver.maximize_window()
# #     # input_box=WebDriverWait(driver,5,0.5).until(lambda p: p.find_element(By.XPATH,"//*[@id='__layout']/div/div[2]/div[3]/div/div/div[3]/div/div/div/input"))
# #     # input_box.send_keys("java")
# #     # input_box.send_keys(Keys.ENTER)
# #
# #     # driver.get("https://www.haohua.com/")
# #     # driver.maximize_window()
# #     # input_box=WebDriverWait(driver,5,0.5).until(lambda p: p.find_element(By.XPATH,"/html/body/div[2]/div/div[1]/div[2]/form/div/input"))
# #     # input_box.send_keys("红玫瑰")
# #     # input_box.send_keys(Keys.ENTER)
# #
# #     # driver.get("https://fund.eastmoney.com/data/fundranking.html#tall;c0;r;s1nzf;pn50;ddesc;qsd20231231;qed20241231;qdii;zq;gg;gzbd;gzfs;bbzt;sfbb")
# #     # driver.maximize_window()
# #     # input_box = WebDriverWait(driver, 5, 0.5).until(lambda p: p.find_element(By.XPATH, "//*[@id='pagebar']/label[8]")).click()
# #     sleep(5)
# #     driver.quit()
